/*
 * Vector.h
 *
 *  Created on: May 26, 2011
 *      Author: gilang
 */

#ifndef VECTOR_H_
#define VECTOR_H_

template<class T>
class Vector {
private:
	T *values;
	int row;
public:
	Vector() {
		values = NULL;
		row = 0;
	}
	Vector(int b) {
		row = b;
		values = new T[row];
	}
	void set(int i, T t) {
		values[i] = t;
	}
	T & operator()(int i) {
		return values[i];
	}
	Vector<T> operator+(const Vector &v) {
		Vector<T> z = Vector<T> (v.row);
		for (int i = 1; i <= z.row; i++)
			z.values[i] = values[i] + v.values[i];
		return z;
	}
	Vector<T> operator-(const Vector &v) {
		Vector<T> z = Vector<T> (v.row);
		for (int i = 1; i <= z.row; i++)
			z.values[i] = values[i] - v.values[i];
		return z;
	}
	Vector<T> operator*(const T &t) {
		for (int i = 1; i <= row; i++)
			values[i] = t*values[i];
		return *this;
	}

	Vector<T> operator=(const Vector<T> &v){
		row=v.row;
		values=v.values;
		return *this;
	}
	virtual ~Vector(){}
};

#endif /* VECTOR_H_ */
